/**
 * Base DAO
 */
class BaseDao {
  /**
   * constructor
   * @param {Model} model
   */
  constructor(model) {
    this.model = model;
  }

  /**
   * create a recode
   * @param {Model} record
   * @return {Model} record
   */
  create(record) {
    return this.model.create(record);
  }

  /**
   * update model
   * @param {Object} values
   * @param {Object} options
   * @return {Promise<Array>}
   */
  update(values, options) {
    return this.model.update(values, options);
  }

  /**
   * find by id
   * @param {Integer} id
   * @return {Model} record
   */
  findById(id) {
    return this.model.findById(id);
  }

  /**
   * find all
   * @param {Object<where>} where
   * @param {Array<include>} include
   * @param {Integer} limit
   * @param {Integer} offset default 0
   * @return {Array<Model>} records
   */
  findAll(where, include, limit, offset = 0) {
    return this.model.findAll({
      where: where,
      include: include,
      limit: limit,
      offset: offset,
    });
  }

  /**
   * find one record
   * @param {Object<where>} where
   * @param {Array<include>} include
   * @param {Integer} limit default 1
   * @param {Integer} offset default 0
   * @return {Model} record
   */
  findOne(where, include, limit, offset = 0) {
    return this.model.findOne({
      where: where,
      include: include,
      limit: limit,
      offset: offset,
    });
  }
}

module.exports = BaseDao;
